#!/bin/bash

# postinst script for system-test-ostest
#
# see: dh_installdeb(1)

#set -e

# summary of how this script can be called:
#        * <postinst> \`configure' <most-recently-configured-version>
#        * <old-postinst> \`abort-upgrade' <new version>
#        * <conflictor's-postinst> \`abort-remove' \`in-favour' <package>
#          <new-version>
#        * <postinst> \`abort-remove'
#        * <deconfigured's-postinst> \`abort-deconfigure' \`in-favour'
#          <failed-install-package> <version> \`removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

PATH=/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
export PATH

if [ "${BASEDIR:=/}" = "/" ]; then
    BASEDIR=""
else
    BASEDIR_OPT="-b $BASEDIR"
fi

case "$1" in
    configure)
	chmod 0444 "$BASEDIR/opt/os-tests/README"
	chown root:bin "$BASEDIR/opt/os-tests/README"
	chmod 0444 "$BASEDIR/opt/os-tests/runfiles/default.run"
	chown root:bin "$BASEDIR/opt/os-tests/runfiles/default.run"
	chmod 0444 "$BASEDIR/opt/os-tests/tests/definit/init.data"
	chown root:bin "$BASEDIR/opt/os-tests/tests/definit/init.data"
	chmod 0444 "$BASEDIR/opt/os-tests/tests/definit/init.expected"
	chown root:bin "$BASEDIR/opt/os-tests/tests/definit/init.expected"
	chmod 0444 "$BASEDIR/opt/os-tests/tests/libtopo/digraph-test-in-badedge.xml"
	chown root:bin "$BASEDIR/opt/os-tests/tests/libtopo/digraph-test-in-badedge.xml"
	chmod 0444 "$BASEDIR/opt/os-tests/tests/libtopo/digraph-test-in-badelement.xml"
	chown root:bin "$BASEDIR/opt/os-tests/tests/libtopo/digraph-test-in-badelement.xml"
	chmod 0444 "$BASEDIR/opt/os-tests/tests/libtopo/digraph-test-in-badnum.xml"
	chown root:bin "$BASEDIR/opt/os-tests/tests/libtopo/digraph-test-in-badnum.xml"
	chmod 0444 "$BASEDIR/opt/os-tests/tests/libtopo/digraph-test-in-badscheme.xml"
	chown root:bin "$BASEDIR/opt/os-tests/tests/libtopo/digraph-test-in-badscheme.xml"
	chmod 0444 "$BASEDIR/opt/os-tests/tests/libtopo/digraph-test-in.xml"
	chown root:bin "$BASEDIR/opt/os-tests/tests/libtopo/digraph-test-in.xml"
	chmod 0555 "$BASEDIR/opt/os-tests/bin/ostest"
	chown root:bin "$BASEDIR/opt/os-tests/bin/ostest"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/clock_gettime.32"
	chown root:bin "$BASEDIR/opt/os-tests/tests/clock_gettime.32"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/clock_gettime.64"
	chown root:bin "$BASEDIR/opt/os-tests/tests/clock_gettime.64"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/cores/core_prereqs"
	chown root:bin "$BASEDIR/opt/os-tests/tests/cores/core_prereqs"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/cores/coretests"
	chown root:bin "$BASEDIR/opt/os-tests/tests/cores/coretests"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/cores/dumper.32"
	chown root:bin "$BASEDIR/opt/os-tests/tests/cores/dumper.32"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/cores/dumper.64"
	chown root:bin "$BASEDIR/opt/os-tests/tests/cores/dumper.64"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/cores/secmapper"
	chown root:bin "$BASEDIR/opt/os-tests/tests/cores/secmapper"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/ddi_ufm/ufm-test"
	chown root:bin "$BASEDIR/opt/os-tests/tests/ddi_ufm/ufm-test"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/ddi_ufm/ufm-test-cleanup"
	chown root:bin "$BASEDIR/opt/os-tests/tests/ddi_ufm/ufm-test-cleanup"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/ddi_ufm/ufm-test-setup"
	chown root:bin "$BASEDIR/opt/os-tests/tests/ddi_ufm/ufm-test-setup"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/definit/definit"
	chown root:bin "$BASEDIR/opt/os-tests/tests/definit/definit"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/definit/definit_test.32"
	chown root:bin "$BASEDIR/opt/os-tests/tests/definit/definit_test.32"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/definit/definit_test.64"
	chown root:bin "$BASEDIR/opt/os-tests/tests/definit/definit_test.64"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/eventfd.32"
	chown root:bin "$BASEDIR/opt/os-tests/tests/eventfd.32"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/eventfd.64"
	chown root:bin "$BASEDIR/opt/os-tests/tests/eventfd.64"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/file-locking/acquire-lock.32"
	chown root:bin "$BASEDIR/opt/os-tests/tests/file-locking/acquire-lock.32"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/file-locking/acquire-lock.64"
	chown root:bin "$BASEDIR/opt/os-tests/tests/file-locking/acquire-lock.64"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/file-locking/runtests.32"
	chown root:bin "$BASEDIR/opt/os-tests/tests/file-locking/runtests.32"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/file-locking/runtests.64"
	chown root:bin "$BASEDIR/opt/os-tests/tests/file-locking/runtests.64"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/i386/badseg"
	chown root:bin "$BASEDIR/opt/os-tests/tests/i386/badseg"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/i386/badseg_exec"
	chown root:bin "$BASEDIR/opt/os-tests/tests/i386/badseg_exec"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/i386/ldt"
	chown root:bin "$BASEDIR/opt/os-tests/tests/i386/ldt"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/imc_test"
	chown root:bin "$BASEDIR/opt/os-tests/tests/imc_test"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/ksensor/ksensor_basic.32"
	chown root:bin "$BASEDIR/opt/os-tests/tests/ksensor/ksensor_basic.32"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/ksensor/ksensor_basic.64"
	chown root:bin "$BASEDIR/opt/os-tests/tests/ksensor/ksensor_basic.64"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/ksensor/ksensor_err.32"
	chown root:bin "$BASEDIR/opt/os-tests/tests/ksensor/ksensor_err.32"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/ksensor/ksensor_err.64"
	chown root:bin "$BASEDIR/opt/os-tests/tests/ksensor/ksensor_err.64"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/ksensor/ksensor_fini"
	chown root:bin "$BASEDIR/opt/os-tests/tests/ksensor/ksensor_fini"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/ksensor/ksensor_init"
	chown root:bin "$BASEDIR/opt/os-tests/tests/ksensor/ksensor_init"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/ksensor/ksensor_sread.32"
	chown root:bin "$BASEDIR/opt/os-tests/tests/ksensor/ksensor_sread.32"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/ksensor/ksensor_sread.64"
	chown root:bin "$BASEDIR/opt/os-tests/tests/ksensor/ksensor_sread.64"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/ksensor/ksensor_stress"
	chown root:bin "$BASEDIR/opt/os-tests/tests/ksensor/ksensor_stress"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/ksensor/ksensor_unload"
	chown root:bin "$BASEDIR/opt/os-tests/tests/ksensor/ksensor_unload"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/libtopo/digraph-test"
	chown root:bin "$BASEDIR/opt/os-tests/tests/libtopo/digraph-test"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/odirectory.32"
	chown root:bin "$BASEDIR/opt/os-tests/tests/odirectory.32"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/odirectory.64"
	chown root:bin "$BASEDIR/opt/os-tests/tests/odirectory.64"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/pf_key/15146"
	chown root:bin "$BASEDIR/opt/os-tests/tests/pf_key/15146"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/pf_key/acquire-compare"
	chown root:bin "$BASEDIR/opt/os-tests/tests/pf_key/acquire-compare"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/pf_key/acquire-spray"
	chown root:bin "$BASEDIR/opt/os-tests/tests/pf_key/acquire-spray"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/pf_key/eacq-enabler"
	chown root:bin "$BASEDIR/opt/os-tests/tests/pf_key/eacq-enabler"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/pf_key/kmc-update"
	chown root:bin "$BASEDIR/opt/os-tests/tests/pf_key/kmc-update"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/pf_key/kmc-updater"
	chown root:bin "$BASEDIR/opt/os-tests/tests/pf_key/kmc-updater"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/poll/epoll_test"
	chown root:bin "$BASEDIR/opt/os-tests/tests/poll/epoll_test"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/poll/poll_test"
	chown root:bin "$BASEDIR/opt/os-tests/tests/poll/poll_test"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/portfs/file_assoc.32"
	chown root:bin "$BASEDIR/opt/os-tests/tests/portfs/file_assoc.32"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/portfs/file_assoc.64"
	chown root:bin "$BASEDIR/opt/os-tests/tests/portfs/file_assoc.64"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/regression/illumos-15031"
	chown root:bin "$BASEDIR/opt/os-tests/tests/regression/illumos-15031"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/regression/illumos-15036"
	chown root:bin "$BASEDIR/opt/os-tests/tests/regression/illumos-15036"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/sdevfs/sdevfs_eisdir"
	chown root:bin "$BASEDIR/opt/os-tests/tests/sdevfs/sdevfs_eisdir"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/secflags/addrs-32"
	chown root:bin "$BASEDIR/opt/os-tests/tests/secflags/addrs-32"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/secflags/addrs-64"
	chown root:bin "$BASEDIR/opt/os-tests/tests/secflags/addrs-64"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/secflags/secflags_aslr"
	chown root:bin "$BASEDIR/opt/os-tests/tests/secflags/secflags_aslr"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/secflags/secflags_core"
	chown root:bin "$BASEDIR/opt/os-tests/tests/secflags/secflags_core"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/secflags/secflags_dts"
	chown root:bin "$BASEDIR/opt/os-tests/tests/secflags/secflags_dts"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/secflags/secflags_elfdump"
	chown root:bin "$BASEDIR/opt/os-tests/tests/secflags/secflags_elfdump"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/secflags/secflags_forbidnullmap"
	chown root:bin "$BASEDIR/opt/os-tests/tests/secflags/secflags_forbidnullmap"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/secflags/secflags_limits"
	chown root:bin "$BASEDIR/opt/os-tests/tests/secflags/secflags_limits"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/secflags/secflags_noexecstack"
	chown root:bin "$BASEDIR/opt/os-tests/tests/secflags/secflags_noexecstack"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/secflags/secflags_proc"
	chown root:bin "$BASEDIR/opt/os-tests/tests/secflags/secflags_proc"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/secflags/secflags_psecflags"
	chown root:bin "$BASEDIR/opt/os-tests/tests/secflags/secflags_psecflags"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/secflags/secflags_syscall"
	chown root:bin "$BASEDIR/opt/os-tests/tests/secflags/secflags_syscall"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/secflags/secflags_truss"
	chown root:bin "$BASEDIR/opt/os-tests/tests/secflags/secflags_truss"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/secflags/secflags_zonecfg"
	chown root:bin "$BASEDIR/opt/os-tests/tests/secflags/secflags_zonecfg"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/secflags/stacky"
	chown root:bin "$BASEDIR/opt/os-tests/tests/secflags/stacky"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/signalfd/basic_args"
	chown root:bin "$BASEDIR/opt/os-tests/tests/signalfd/basic_args"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/signalfd/basic_read"
	chown root:bin "$BASEDIR/opt/os-tests/tests/signalfd/basic_read"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/signalfd/multipoll"
	chown root:bin "$BASEDIR/opt/os-tests/tests/signalfd/multipoll"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/sigqueue/sigqueue_queue_size"
	chown root:bin "$BASEDIR/opt/os-tests/tests/sigqueue/sigqueue_queue_size"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/sockfs/conn"
	chown root:bin "$BASEDIR/opt/os-tests/tests/sockfs/conn"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/sockfs/dgram"
	chown root:bin "$BASEDIR/opt/os-tests/tests/sockfs/dgram"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/sockfs/drop_priv"
	chown root:bin "$BASEDIR/opt/os-tests/tests/sockfs/drop_priv"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/sockfs/nosignal"
	chown root:bin "$BASEDIR/opt/os-tests/tests/sockfs/nosignal"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/sockfs/recvmsg.32"
	chown root:bin "$BASEDIR/opt/os-tests/tests/sockfs/recvmsg.32"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/sockfs/recvmsg.64"
	chown root:bin "$BASEDIR/opt/os-tests/tests/sockfs/recvmsg.64"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/sockfs/rights.32"
	chown root:bin "$BASEDIR/opt/os-tests/tests/sockfs/rights.32"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/sockfs/rights.64"
	chown root:bin "$BASEDIR/opt/os-tests/tests/sockfs/rights.64"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/sockfs/sockpair"
	chown root:bin "$BASEDIR/opt/os-tests/tests/sockfs/sockpair"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/spoof-ras"
	chown root:bin "$BASEDIR/opt/os-tests/tests/spoof-ras"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/stackalign/stackalign.32"
	chown root:bin "$BASEDIR/opt/os-tests/tests/stackalign/stackalign.32"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/stackalign/stackalign.64"
	chown root:bin "$BASEDIR/opt/os-tests/tests/stackalign/stackalign.64"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/stress/dladm-kstat"
	chown root:bin "$BASEDIR/opt/os-tests/tests/stress/dladm-kstat"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/syscall/fchmodat.32"
	chown root:bin "$BASEDIR/opt/os-tests/tests/syscall/fchmodat.32"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/syscall/fchmodat.64"
	chown root:bin "$BASEDIR/opt/os-tests/tests/syscall/fchmodat.64"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/syscall/open.32"
	chown root:bin "$BASEDIR/opt/os-tests/tests/syscall/open.32"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/syscall/open.64"
	chown root:bin "$BASEDIR/opt/os-tests/tests/syscall/open.64"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/timer/timer_limit"
	chown root:bin "$BASEDIR/opt/os-tests/tests/timer/timer_limit"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/uccid/atrparse"
	chown root:bin "$BASEDIR/opt/os-tests/tests/uccid/atrparse"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/uccid/excl-badread"
	chown root:bin "$BASEDIR/opt/os-tests/tests/uccid/excl-badread"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/uccid/excl-basic"
	chown root:bin "$BASEDIR/opt/os-tests/tests/uccid/excl-basic"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/uccid/excl-close"
	chown root:bin "$BASEDIR/opt/os-tests/tests/uccid/excl-close"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/uccid/excl-loop"
	chown root:bin "$BASEDIR/opt/os-tests/tests/uccid/excl-loop"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/uccid/excl-nonblock"
	chown root:bin "$BASEDIR/opt/os-tests/tests/uccid/excl-nonblock"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/uccid/excl-reset"
	chown root:bin "$BASEDIR/opt/os-tests/tests/uccid/excl-reset"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/uccid/modify"
	chown root:bin "$BASEDIR/opt/os-tests/tests/uccid/modify"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/uccid/notxn-poll"
	chown root:bin "$BASEDIR/opt/os-tests/tests/uccid/notxn-poll"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/uccid/pollin"
	chown root:bin "$BASEDIR/opt/os-tests/tests/uccid/pollin"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/uccid/pollout"
	chown root:bin "$BASEDIR/opt/os-tests/tests/uccid/pollout"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/uccid/status"
	chown root:bin "$BASEDIR/opt/os-tests/tests/uccid/status"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/uccid/txn-pollerr"
	chown root:bin "$BASEDIR/opt/os-tests/tests/uccid/txn-pollerr"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/uccid/yk"
	chown root:bin "$BASEDIR/opt/os-tests/tests/uccid/yk"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/uccid/yk-poll"
	chown root:bin "$BASEDIR/opt/os-tests/tests/uccid/yk-poll"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/uccid/yk-readonly"
	chown root:bin "$BASEDIR/opt/os-tests/tests/uccid/yk-readonly"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/ucontext.32"
	chown root:bin "$BASEDIR/opt/os-tests/tests/ucontext.32"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/ucontext.64"
	chown root:bin "$BASEDIR/opt/os-tests/tests/ucontext.64"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/writev.32"
	chown root:bin "$BASEDIR/opt/os-tests/tests/writev.32"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/writev.64"
	chown root:bin "$BASEDIR/opt/os-tests/tests/writev.64"
	chmod 0555 "$BASEDIR/opt/os-tests/tests/zen_umc_test"
	chown root:bin "$BASEDIR/opt/os-tests/tests/zen_umc_test"
	chmod 0755 "$BASEDIR/opt/os-tests/tests/cores/amd64/libdumper.so.1"
	chown root:bin "$BASEDIR/opt/os-tests/tests/cores/amd64/libdumper.so.1"
	chmod 0755 "$BASEDIR/opt/os-tests/tests/cores/libdumper.so.1"
	chown root:bin "$BASEDIR/opt/os-tests/tests/cores/libdumper.so.1"
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/kernel/drv/ksensor_test.conf ] && rm -f $BASEDIR/kernel/drv/ksensor_test.conf
	else
	    chmod 0644 "$BASEDIR/kernel/drv/ksensor_test.conf"
	    chown root:sys "$BASEDIR/kernel/drv/ksensor_test.conf"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/kernel/drv/amd64/ksensor_test ] && rm -f $BASEDIR/kernel/drv/amd64/ksensor_test
	else
	    chmod 0755 "$BASEDIR/kernel/drv/amd64/ksensor_test"
	    chown root:sys "$BASEDIR/kernel/drv/amd64/ksensor_test"
	fi
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument '$1'" >&2
        exit 1
    ;;
esac



# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0

